﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ksp.Interface;


namespace ksp.Controller
{
    public static class UomParser
    {
        private static char[] seperator = {','};

        /// <summary>
        /// Parse Coordination Value
        /// </summary>
        /// <param name="coords">KSP Coordination String</param>
        /// <returns></returns>
        public static UnitsOfMeasurement.Coordinations ParseCoordinates(String coords)
        {
            UnitsOfMeasurement.Coordinations coordinations = new UnitsOfMeasurement.Coordinations();
            String[] coordArr = coords.Split(seperator);

            coordinations.X = Double.Parse(coordArr[0]);
            coordinations.Y = Double.Parse(coordArr[1]);
            coordinations.Z = Double.Parse(coordArr[2]);

            return coordinations;
        }

        /// <summary>
        /// Parse Rotation Value
        /// </summary>
        /// <param name="rot">KSP Rotation String</param>
        /// <returns></returns>
        public static UnitsOfMeasurement.Rotation ParseRotation(String rot)
        {
            UnitsOfMeasurement.Rotation rotation = new UnitsOfMeasurement.Rotation();
            String[] rotArr = rot.Split(seperator);

            rotation.X = Double.Parse(rotArr[0]);
            rotation.Y = Double.Parse(rotArr[1]);
            rotation.Z = Double.Parse(rotArr[2]);
            rotation.N = Double.Parse(rotArr[3]);

            return rotation;
        }
    }
}
